import ViewUI from 'view-design'

const utils = {
  copy: function (text) {
    let input = document.createElement('input')
    input.setAttribute('readonly', 'readonly')
    input.setAttribute('value', text)
    document.body.appendChild(input)
    input.setSelectionRange(0, text.length)
    input.select()
    if (document.execCommand('copy')) {
      document.execCommand('copy')
      ViewUI.Message.success('复制成功')
    }
    document.body.removeChild(input)
  },
}
export default utils
